package demo2;

/**
 * @Author liangzai
 * @Description:
 */

class Myval{
    public int val;
}


public class Test {
    public static void swap(Myval val1,Myval val2){
        int tmp = val1.val;
        val1.val=val2.val;
        val2.val=tmp;
    }

    public static void main(String[] args) {
        Myval myval1=new Myval();
        Myval myval2=new Myval();

        myval1.val=10;
        myval2.val=20;
        System.out.println("交换前："+myval1.val+" "+myval2.val);
        swap(myval1,myval2);
        System.out.println("交换后："+myval1.val+" "+myval2.val);

    }
}
